//
//  ZFVideoListCell.m
//  TestPrj
//
//  Created by 朱铅峰 on 2019/12/24.
//  Copyright © 2019 Xing. All rights reserved.
//

#import "ZFVideoListCell.h"
#import <SDWebImage/SDWebImage.h>
#import <Masonry.h>
#import <MJRefresh.h>

@interface ZFVideoListCell()

@property (nonatomic, strong) NSIndexPath *indexPath;
@property (nonatomic, strong) UIButton *playBtn;

@end

@implementation ZFVideoListCell

- (void)awakeFromNib {
    
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.videoContainerView.tag = [ZFVideoListCell videoContainerViewTag];//已外部调用的tag值一致
    
    self.playBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.playBtn.imageEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
    [self.playBtn setImage:[UIImage imageNamed:@"new_allPlay_44x44_"] forState:UIControlStateNormal];
    [self.playBtn addTarget:self action:@selector(playBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.videoContainerView addSubview:self.playBtn];
    [self.playBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(44);
        make.center.mas_equalTo(self.videoContainerView);
    }];
}

+ (NSInteger)videoContainerViewTag {
    
    return 10001;
}

- (void)loadData:(ZFTableData *)data {
    
    [self.avatarView sd_setImageWithURL:[NSURL URLWithString:data.head]];
    
    self.titleLabel.text = data.nick_name;
    
    [self.videoContainerView sd_setImageWithURL:[NSURL URLWithString:data.thumbnail_url]];
    
    self.descLabel.text = data.title;
}

- (void)playBtnAction {
    
    if (self.playVideoWithIndexPathAction) {
        self.playVideoWithIndexPathAction(self.indexPath);
    }
}

@end
